home *** CD-ROM | disk | FTP | other *** search
Text File | 1992-07-15 | 3.6 KB | 107 lines | [TEXT/MPS ] |
- {[n+,u+,r+,d+,#+,j=13-/40/1o,t=2,o=95] PasMat formatting options}
-
- {------------------------------------------------------------------------------
-
- FILE SetPDiMC.p
- Copyright Zz 1990
- All rights revoked.
-
- NAME
- SetPDiMC -- An MPW tool to set the 'Printer Driver is MultiFinder Compatible' flag.
-
- SYNOPSIS
- SetPDiMC <filename>
-
- DESCRIPTION
- "SetPDiMC" automates the process of creating a printer driver. The last step in
- the process is usually to set the 'Printer Driver is MultiFinder Compatible' flag
- that tells MultiFinder special things about handling the resources (see Learning
- To Drive for more information about the PDiMC flag). This tool can be called from
- a makefile, and will simply set the PDiMC flag.
-
- ------------------------------------------------------------------------------}
- {$R-} { Turn off range checking}
- PROGRAM AbbreviateFName;
-
- USES { $Load macstuff}
- Memtypes, Quickdraw, OSIntf, ToolIntf, PackIntf, { Standard Includes}
- { $Load mpwstuff}
- CursorCtl, { for the spinning cursor}
- Signal, { to handle command-period}
- PasLibIntf, { for standard I/O, etc.}
- IntEnv; { for argV and argC}
-
-
- {$S Main}
- {*--------------------------------------*
- | DoIt -- check resources in each file |
- *--------------------------------------*}
-
- PROCEDURE DoIt; { the guts of our program--in a procedure so the
- compiler can do register optimizations}
- VAR
- argVIndex: INTEGER;
- strIndex: INTEGER;
- arg: Str255;
- fileName: Str255;
- theError: INTEGER;
- theFile: INTEGER;
- theAttrs: INTEGER;
- tester: Handle;
-
- BEGIN {DoIt}
- argVIndex := 1;
- WHILE argVIndex < ArgC DO BEGIN {ArgC is the number of args plus one}
- arg := ArgV^[argVIndex]^;
- IF (LENGTH(arg) <> 0) THEN BEGIN
- IF arg[1] = '-' THEN BEGIN { we have an option }
- { No options yet... }
- END ELSE BEGIN { it must be the font name}
- fileName := arg;
- END;
- END;
- argVIndex := argVIndex + 1;
- END;
-
- (* Begin by opening the file. You need to do this to call GetResFileAttrs. *)
- theFile := OpenResFile(fileName);
- theError := ResError;
- IF theError <> noErr THEN
- WRITELN(Diagnostic, 'Error opening: ', theError)
- ELSE BEGIN
- (* Point to the file we just opened. *)
- UseResFile(theFile);
-
- (* Load a resource we know will be there. PDEF 4 is used to handle the *)
- (* Printing Manager dialogs, so there should be one. *)
- tester := GetResource('PDEF', 4);
-
- (* Now get the current resource file attributes. *)
- theAttrs := GetResFileAttrs(theFile);
-
- (* Set the flag that we're interested in. The lowest bit. *)
- theAttrs := BitOr(theAttrs, 1);
-
- (* Now set the attributes and check for errors. *)
- SetResFileAttrs(theFile, theAttrs);
- theError := ResError;
- IF (theError <> noErr) THEN
- WRITELN(Diagnostic, 'Error setting attributes: ', theError);
-
- (* Now we need to mark at least one resource as being changed so that the *)
- (* Resource Manager will write out the resource map of this file, thus *)
- (* setting the attributes. If this is not done, the call to SetResFileAttrs *)
- (* will be ignored. *)
- ChangedResource(tester);
- END;
- (* Finally close the file... *)
- CloseResFile(theFile);
- END; {DoIt}
-
- {*----------------------------*
- | Abbreviate -- main program |
- *----------------------------*}
- BEGIN {Abbreviate}
- DoIt; { and call our routine}
- END. {Abbreviate}
-